<%@ page import="entity.User" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table>
  <tr>
    <th>id</th>
    <th>username</th>
    <th>password</th>
  </tr>
<%--jsp 中写java代码 在<%%>--%>
  <% List<User> users = (List<User>) request.getAttribute("userList");
    for (User user : users) {
  %>
  <tr>
    <td><%=user.getId()%></td>
    <td><%=user.getUsername()%></td>
    <td><%=user.getPassword()%></td>
  </tr>
  <%
    }
  %>
<%--  遍历得到--%>
</table>

<jsp:useBean id="u" class="entity.User"/>

<jsp:setProperty name="u" property="id" value="5"/>
<jsp:setProperty name="u" property="username" value="wangwu"/>
<jsp:setProperty name="u" property="password" value="555"/>

<jsp:getProperty name="u" property="id"/>
<jsp:getProperty name="u" property="username"/>
<jsp:getProperty name="u" property="password"/>

<%--转发--%>
<%--<jsp:forward page="index.jsp"/>--%>

<% String req = (String) request.getAttribute("key1");
  String s = (String) request.getSession().getAttribute("key2");
  String s1 = (String) session.getAttribute("key2");
  String a = (String) application.getAttribute("key3");
  pageContext.setAttribute("key4","value4");
  Object key4 = pageContext.getAttribute("key4");
%>
<%= req%>
<%= s%>
<%= s1%>
<%= a%>
<%= key4%>
<br/>
<%--EL--%>
${key1}
${key2}
${key3}
${key4}

<br>
<% String method = request.getMethod();
  String id = request.getSession().getId();
  String contextPath = request.getContextPath();
  String serverName = request.getServerName();
%>
<%=method%><br>
<%=id%><br>
<%=contextPath%><br>
<%=serverName%><br>
---------------<br>
${pageContext.request.method}<br>
${pageContext.session.id}<br>
${pageContext.request.contextPath}<br>
${pageContext.request.serverName}<br>

${5==5 && 5<6}
<br>
<%--判断空值--%>
${empty requestScope.emptyNull}
${empty emptyStr}
${empty emptyArr}
${empty emptyList}
${empty emptyMap}
<br>
<%--三元运算符--%>
${5 eq 5? "true":"false"}
</body>
</html>
